﻿using Direct.IDAL.User.Jurisdiction;
using DirectSell.Common.Filter;
using DirectSell.Common.Session;
using DirectSell.IBLL;
using DirectSell.Model.User;
using Microsoft.Practices.Unity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace DirectSell.WebLayer.Areas.User.Controllers.Jurisdiction
{
    /// <summary>
    /// 修改资料
    /// </summary>
    public class ModifyInfoController : Controller
    {

        #region 依赖注入--郭文昊--2018年10月29日12:13:113
        /// <summary>
        /// 修改资料接口
        /// </summary>
        [Dependency("UserModify")]
        protected IOperation modify { get; set; }

        [Dependency]
        protected IModifyInfoRespository modifydal { get; set; }

        #endregion

        #region 首页
        /// <summary>
        /// 修改资料首页
        /// </summary>
        /// <returns></returns>
        [LoginFilter(IsCheck =true)]
        public async Task<ActionResult> Index()
        {
            var model = await GetInfo();
            return View(model);
        }
        #endregion

        #region 获取会员信息
        /// <summary>
        /// 获取会员信息
        /// </summary>
        /// <returns></returns>
        public async Task<UserInforMationDetails> GetInfo()
        {
            var usercode = SessionInfo.GetSession().UserCode;
            return await modifydal.GetInfo(usercode);
        }
        #endregion

        #region 修改资料
        /// <summary>
        /// 修改资料
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task<UserRespCode> Modify(UserInforMationDetails model)
        {
            model.UserCode = SessionInfo.GetSession().UserCode;
            return await modify.DoOperationAsync(model);
        }
        #endregion

    }
}